<?php

namespace common\models\Guest;

use Yii;
use common\models\Activity\Activity;
/**
 * This is the model class for table "guest".
 *
 * @property integer $g_id
 * @property string $g_name
 * @property string $g_position
 * @property string $g_company
 * @property integer $adm_id
 * @property string $g_state
 * @property string $g_description
 * @property integer $ac_id
 */
class Guest extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'guest';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['g_name', 'g_position', 'g_company', 'adm_id', 'g_state', 'g_description', 'ac_id'], 'required'],
            [['adm_id', 'ac_id'], 'integer'],
            [['g_name', 'g_position', 'g_company', 'g_state', 'g_description'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'g_id' => Yii::t('app', '嘉宾列表'),
            'g_name' => Yii::t('app', '嘉宾名称'),
            'g_position' => Yii::t('app', '职位'),
            'g_company' => Yii::t('app', '所属公司'),
            'adm_id' => Yii::t('app', '门票'),
            'g_state' => Yii::t('app', '支付状态'),
            'g_description' => Yii::t('app', '嘉宾简介'),
            'ac_id' => Yii::t('app', '活动名称'),
        ];
    }
     public static function getActivity($id){
         if(Activity::findOne($id)){
            return Activity::findOne($id)->ac_name;
        }else{
            return '';
        }
    }
}
